package com.tssm.core.util;

import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FormatUtil {
	public static final Format FORMAT_ONE = new SimpleDateFormat(
			"yyyyMMddHHmmss");

	public static final Format FORMAT_TWO = new SimpleDateFormat("yyyy-MM-dd");

	public static final Format FORMAT_THREE = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm:ss");

	public static final Format FORMAT_FOUR = new SimpleDateFormat("yyyy");

	public static final Format FORMAT_FIVE = new SimpleDateFormat("MM");

	public static final Format FORMAT_SIX = new SimpleDateFormat(
			"yyyy-MM-dd-HH-mm-ss");

	/**
	 * 
	 * 
	 * @方法说明:得到时间形式转化为字符串类型(yyyyMMddHHmmss)
	 * @param date
	 * @return
	 * @作者:徐龙
	 * @日期:2011-5-17
	 */
	public static String getFormatTime(Date date) {
		return getFormatTime(FORMAT_ONE, date);
	}

	public static String getFormatTwoTime(Date date) {
		return getFormatTime(FORMAT_TWO, date);
	}
	public static String getFormatThreeTime(Date date) {
		return getFormatTime(FORMAT_THREE, date);
	}

	/**
	 * 
	 * 
	 * @方法说明:时间形式转化为字符串类型
	 * @param format
	 * @param date
	 * @return
	 * @作者:徐龙
	 * @日期:2011-5-17
	 */
	public static String getFormatTime(Format format, Date date) {
		return format.format(date);
	}

	/**
	 * 
	 * 
	 * @方法说明:字符串类型(yyyyMMddHHmmss)转化为时间形式
	 * @param formatTime
	 * @return
	 * @作者:徐龙
	 * @日期:2011-5-17
	 */
	public static Date getDateTime(String formatTime) {
		return getDateTime(FORMAT_ONE, formatTime);
	}

	public static Date getDateTwoTime(String formatTime) {
		return getDateTime(FORMAT_TWO, formatTime);
	}
	
	public static Date getDateThreeTime(String formatTime) {
		return getDateTime(FORMAT_THREE, formatTime);
	}

	/**
	 * 
	 * 
	 * @方法说明:字符串类型转化为时间形式
	 * @param format
	 * @param formatTime
	 * @return
	 * @作者:徐龙
	 * @日期:2011-5-17
	 */
	public static Date getDateTime(Format format, String formatTime) {
		Date dateTime = null;
		try {
			dateTime = (Date) format.parseObject(formatTime);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return dateTime;
	}

}
